package com.example.test.service;

import com.example.test.entity.Role;
import com.example.test.mapper.UserRoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Service
public class UserRoleService {

    @Autowired
    UserRoleMapper userRoleMapper;

    public Set<String> getRoleName(Integer userId){
        Set<String> roleName = new HashSet<>();
        List<Role> roles = userRoleMapper.getRoleByUid(userId);
        for (Role r:roles) {
            roleName.add(r.getName());
        }
        return roleName;
    }


}
